sw = gtk_scrolled_window_new (NULL, NULL);
gtk_window_set_child (GTK_WINDOW (window), sw);
- listview = gtk_list_view_new ();
+ listview = gtk_list_view_new_with_factory (
+ gtk_functions_list_item_factory_new (setup_widget,
+ bind_widget,
+ NULL, NULL));
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
- gtk_list_view_set_functions (GTK_LIST_VIEW (listview),
- setup_widget,
- bind_widget,
- NULL, NULL);
model = create_weather_model ();
selection = G_LIST_MODEL (gtk_no_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
gtk_list_item_factory_get_type
</SECTION>
+<SECTION>
+<FILE>gtkbuilderlistitemfactory</FILE>
+<TITLE>GtkBuilderListItemFactory</TITLE>
+GtkBuilderListItemFactory
+gtk_builder_list_item_factory_new_from_bytes
+gtk_builder_list_item_factory_new_from_resource
+gtk_builder_list_item_factory_get_bytes
+gtk_builder_list_item_factory_get_resource
+gtk_builder_list_item_factory_get_scope
+<SUBSECTION Standard>
+GTK_BUILDER_LIST_ITEM_FACTORY
+GTK_BUILDER_LIST_ITEM_FACTORY_CLASS
+GTK_BUILDER_LIST_ITEM_FACTORY_GET_CLASS
+GTK_IS_BUILDER_LIST_ITEM_FACTORY
+GTK_IS_BUILDER_LIST_ITEM_FACTORY_CLASS
+GTK_TYPE_BUILDER_LIST_ITEM_FACTORY
+<SUBSECTION Private>
+gtk_builder_list_item_factory_get_type
+</SECTION>
+
<SECTION>
<FILE>gtklistview</FILE>
<TITLE>GtkListView</TITLE>
GtkListView
gtk_list_view_new
+gtk_list_view_new_with_factory
+gtk_list_view_set_factory
+gtk_list_view_get_factory
gtk_list_view_set_model
gtk_list_view_get_model
gtk_list_view_set_show_separators
gtk_bin_layout_get_type
gtk_box_get_type
gtk_box_layout_get_type
+gtk_buildable_get_type
gtk_builder_cscope_get_type
gtk_builder_get_type
+gtk_builder_list_item_factory_get_type
gtk_builder_scope_get_type
-gtk_buildable_get_type
gtk_button_get_type
gtk_calendar_get_type
gtk_cell_area_get_type
#include <gtk/gtkbox.h>
#include <gtk/gtkbuildable.h>
#include <gtk/gtkbuilder.h>
+#include <gtk/gtkbuilderlistitemfactory.h>
#include <gtk/gtkbuilderscope.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcalendar.h>
#include <gtk/gtkfontchooserdialog.h>
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkframe.h>
+#include <gtk/gtkfunctionslistitemfactory.h>
#include <gtk/gtkgesture.h>
#include <gtk/gtkgestureclick.h>
#include <gtk/gtkgesturedrag.h>
#include <gtk/gtklinkbutton.h>
#include <gtk/gtklistbox.h>
#include <gtk/gtklistitem.h>
+#include <gtk/gtklistitemfactory.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtklistview.h>
#include <gtk/gtklockbutton.h>
#include "config.h"
-#include "gtkbuilderlistitemfactoryprivate.h"
+#include "gtkbuilderlistitemfactory.h"
#include "gtkbuilder.h"
+#include "gtklistitemfactoryprivate.h"
#include "gtklistitemprivate.h"
+/**
+ * SECTION:gtkbuilderlistitemfactory
+ * @Tiitle: GtkBuilderListItemFactory
+ * @Short_description: A listitem factory using ui files
+ *
+ * #GtkBuilderListItemFactory is a #GtkListItemFactory that creates
+ * widgets by instantiating #GtkBuilder UI templates. The templates
+ * must be extending #GtkListItem, and typically use #GtkExpressions
+ * to obtain data from the items in the model.
+ *
+ * Example:
+ * |[
+ * <interface>
+ * <template class="GtkListItem">
+ * <property name="child">
+ * <object class="GtkLabel">
+ * <property name="xalign">0</property>
+ * <binding name="label">
+ * <lookup name="name" type="SettingsKey">
+ * <lookup name="item">GtkListItem</lookup>
+ * </lookup>
+ * </binding>
+ * </object>
+ * </property>
+ * </template>
+ * </interface>
+ * ]|
+ */
+
struct _GtkBuilderListItemFactory
{
GtkListItemFactory parent_instance;
{
}
+/**
+ * gtk_builder_list_item_factory_new_from_bytes:
+ * @bytes: the bytes containing the ui file to instantiate
+ *
+ * Creates s new #GtkBuilderListItemFactory that instantiates widgets
+ * using @bytes as the data to pass to #GtkBuilder.
+ *
+ * Returns: a new #GtkBuilderListItemFactory
+ **/
GtkListItemFactory *
gtk_builder_list_item_factory_new_from_bytes (GBytes *bytes)
{
return GTK_LIST_ITEM_FACTORY (self);
}
+/**
+ * gtk_builder_list_item_factory_new_from_resource:
+ * @resource_path: valid path to a resource that contains the data
+ *
+ * Creates s new #GtkBuilderListItemFactory that instantiates widgets
+ * using data read from the given @resource_path to pass to #GtkBuilder.
+ *
+ * Returns: a new #GtkBuilderListItemFactory
+ **/
GtkListItemFactory *
gtk_builder_list_item_factory_new_from_resource (const char *resource_path)
{
--- /dev/null
+/*
+ * Copyright © 2019 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_BUILDER_LIST_ITEM_FACTORY_H__
+#define __GTK_BUILDER_LIST_ITEM_FACTORY_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtklistitemfactory.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_BUILDER_LIST_ITEM_FACTORY (gtk_builder_list_item_factory_get_type ())
+#define GTK_BUILDER_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactory))
+#define GTK_BUILDER_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactoryClass))
+#define GTK_IS_BUILDER_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY))
+#define GTK_IS_BUILDER_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY))
+#define GTK_BUILDER_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactoryClass))
+
+typedef struct _GtkBuilderListItemFactory GtkBuilderListItemFactory;
+typedef struct _GtkBuilderListItemFactoryClass GtkBuilderListItemFactoryClass;
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_builder_list_item_factory_get_type (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_ALL
+GtkListItemFactory * gtk_builder_list_item_factory_new_from_bytes (GBytes *bytes);
+GDK_AVAILABLE_IN_ALL
+GtkListItemFactory * gtk_builder_list_item_factory_new_from_resource (const char *resource_path);
+
+
+G_END_DECLS
+
+#endif /* __GTK_BUILDER_LIST_ITEM_FACTORY_H__ */
+++ /dev/null
-/*
- * Copyright © 2019 Benjamin Otte
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Benjamin Otte <otte@gnome.org>
- */
-
-
-#ifndef __GTK_BUILDER_LIST_ITEM_FACTORY_H__
-#define __GTK_BUILDER_LIST_ITEM_FACTORY_H__
-
-#include "gtklistitemfactoryprivate.h"
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_BUILDER_LIST_ITEM_FACTORY (gtk_builder_list_item_factory_get_type ())
-#define GTK_BUILDER_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactory))
-#define GTK_BUILDER_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactoryClass))
-#define GTK_IS_BUILDER_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY))
-#define GTK_IS_BUILDER_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY))
-#define GTK_BUILDER_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_BUILDER_LIST_ITEM_FACTORY, GtkBuilderListItemFactoryClass))
-
-typedef struct _GtkBuilderListItemFactory GtkBuilderListItemFactory;
-typedef struct _GtkBuilderListItemFactoryClass GtkBuilderListItemFactoryClass;
-
-GType gtk_builder_list_item_factory_get_type (void) G_GNUC_CONST;
-
-GtkListItemFactory * gtk_builder_list_item_factory_new_from_bytes (GBytes *bytes);
-GtkListItemFactory * gtk_builder_list_item_factory_new_from_resource (const char *resource_path);
-
-
-G_END_DECLS
-
-#endif /* __GTK_BUILDER_LIST_ITEM_FACTORY_H__ */
#include "config.h"
-#include "gtkfunctionslistitemfactoryprivate.h"
+#include "gtkfunctionslistitemfactory.h"
+#include "gtklistitemfactoryprivate.h"
#include "gtklistitemprivate.h"
struct _GtkFunctionsListItemFactory
--- /dev/null
+/*
+ * Copyright © 2019 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
+#define __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtklistitemfactory.h>
+#include <gtk/gtklistitem.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY (gtk_functions_list_item_factory_get_type ())
+#define GTK_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactory))
+#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
+#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
+#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
+#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
+
+typedef struct _GtkFunctionsListItemFactory GtkFunctionsListItemFactory;
+typedef struct _GtkFunctionsListItemFactoryClass GtkFunctionsListItemFactoryClass;
+
+/**
+ * GtkListItemSetupFunc:
+ * @item: the #GtkListItem to set up
+ * @user_data: (closure): user data
+ *
+ * Called whenever a new list item needs to be setup for managing a row in
+ * the list.
+ *
+ * At this point, the list item is not bound yet, so gtk_list_item_get_item()
+ * will return %NULL.
+ * The list item will later be bound to an item via the #GtkListItemBindFunc.
+ */
+typedef void (* GtkListItemSetupFunc) (GtkListItem *item, gpointer user_data);
+
+/**
+ * GtkListItemBindFunc:
+ * @item: the #GtkListItem to bind
+ * @user_data: (closure): user data
+ *
+ * Binds a#GtkListItem previously set up via a #GtkListItemSetupFunc to
+ * an @item.
+ *
+ * Rebinding a @item to different @items is supported as well as
+ * unbinding it by setting @item to %NULL.
+ */
+typedef void (* GtkListItemBindFunc) (GtkListItem *item,
+ gpointer user_data);
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_functions_list_item_factory_get_type (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_ALL
+GtkListItemFactory * gtk_functions_list_item_factory_new (GtkListItemSetupFunc setup_func,
+ GtkListItemBindFunc bind_func,
+ gpointer user_data,
+ GDestroyNotify user_destroy);
+
+
+G_END_DECLS
+
+#endif /* __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__ */
+++ /dev/null
-/*
- * Copyright © 2019 Benjamin Otte
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Benjamin Otte <otte@gnome.org>
- */
-
-
-#ifndef __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
-#define __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
-
-#include "gtklistitemfactoryprivate.h"
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY (gtk_functions_list_item_factory_get_type ())
-#define GTK_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactory))
-#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
-#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
-#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
-#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
-
-typedef struct _GtkFunctionsListItemFactory GtkFunctionsListItemFactory;
-typedef struct _GtkFunctionsListItemFactoryClass GtkFunctionsListItemFactoryClass;
-
-GType gtk_functions_list_item_factory_get_type (void) G_GNUC_CONST;
-
-GtkListItemFactory * gtk_functions_list_item_factory_new (GtkListItemSetupFunc setup_func,
- GtkListItemBindFunc bind_func,
- gpointer user_data,
- GDestroyNotify user_destroy);
-
-
-G_END_DECLS
-
-#endif /* __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__ */
GDK_AVAILABLE_IN_ALL
GType gtk_list_item_get_type (void) G_GNUC_CONST;
-/**
- * GtkListItemSetupFunc:
- * @item: the #GtkListItem to set up
- * @user_data: (closure): user data
- *
- * Called whenever a new list item needs to be setup for managing a row in
- * the list.
- *
- * At this point, the list item is not bound yet, so gtk_list_item_get_item()
- * will return %NULL.
- * The list item will later be bound to an item via the #GtkListItemBindFunc.
- */
-typedef void (* GtkListItemSetupFunc) (GtkListItem *item, gpointer user_data);
-
-/**
- * GtkListItemBindFunc:
- * @item: the #GtkListItem to bind
- * @user_data: (closure): user data
- *
- * Binds a#GtkListItem previously set up via a #GtkListItemSetupFunc to
- * an @item.
- *
- * Rebinding a @item to different @items is supported as well as
- * unbinding it by setting @item to %NULL.
- */
-typedef void (* GtkListItemBindFunc) (GtkListItem *item,
- gpointer user_data);
-
GDK_AVAILABLE_IN_ALL
gpointer gtk_list_item_get_item (GtkListItem *self);
GDK_AVAILABLE_IN_ALL
--- /dev/null
+/*
+ * Copyright © 2019 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_LIST_ITEM_FACTORY_H__
+#define __GTK_LIST_ITEM_FACTORY_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+typedef struct _GtkListItemFactoryClass GtkListItemFactoryClass;
+
+#include <gdk/gdk.h>
+#include <gtk/gtktypes.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_LIST_ITEM_FACTORY (gtk_list_item_factory_get_type ())
+#define GTK_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactory))
+#define GTK_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactoryClass))
+#define GTK_IS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_LIST_ITEM_FACTORY))
+#define GTK_IS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_LIST_ITEM_FACTORY))
+#define GTK_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactoryClass))
+
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_list_item_factory_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif /* __GTK_LIST_ITEM_FACTORY_H__ */
*/
-#ifndef __GTK_LIST_ITEM_FACTORY_H__
-#define __GTK_LIST_ITEM_FACTORY_H__
+#ifndef __GTK_LIST_ITEM_FACTORY_PRIVATE_H__
+#define __GTK_LIST_ITEM_FACTORY_PRIVATE_H__
#include <gtk/gtklistitem.h>
+#include <gtk/gtklistitemfactory.h>
#include <gtk/gtklistview.h>
G_BEGIN_DECLS
-#define GTK_TYPE_LIST_ITEM_FACTORY (gtk_list_item_factory_get_type ())
-#define GTK_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactory))
-#define GTK_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactoryClass))
-#define GTK_IS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_LIST_ITEM_FACTORY))
-#define GTK_IS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_LIST_ITEM_FACTORY))
-#define GTK_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_LIST_ITEM_FACTORY, GtkListItemFactoryClass))
-
-typedef struct _GtkListItemFactory GtkListItemFactory;
-typedef struct _GtkListItemFactoryClass GtkListItemFactoryClass;
-
struct _GtkListItemFactory
{
GObject parent_instance;
GtkListItem *list_item);
};
-GType gtk_list_item_factory_get_type (void) G_GNUC_CONST;
-
void gtk_list_item_factory_setup (GtkListItemFactory *self,
GtkListItem *list_item);
void gtk_list_item_factory_teardown (GtkListItemFactory *self,
G_END_DECLS
-#endif /* __GTK_LIST_ITEM_FACTORY_H__ */
+#endif /* __GTK_LIST_ITEM_FACTORY_PRIVATE_H__ */
#include "gtklistview.h"
#include "gtkadjustment.h"
-#include "gtkbuilderlistitemfactoryprivate.h"
-#include "gtkfunctionslistitemfactoryprivate.h"
#include "gtkintl.h"
#include "gtklistitemmanagerprivate.h"
#include "gtkorientableprivate.h"
enum
{
PROP_0,
+ PROP_FACTORY,
PROP_HADJUSTMENT,
PROP_HSCROLL_POLICY,
PROP_MODEL,
switch (property_id)
{
+ case PROP_FACTORY:
+ g_value_set_object (value, gtk_list_item_manager_get_factory (self->item_manager));
+ break;
+
case PROP_HADJUSTMENT:
g_value_set_object (value, self->adjustment[GTK_ORIENTATION_HORIZONTAL]);
break;
switch (property_id)
{
+ case PROP_FACTORY:
+ gtk_list_view_set_factory (self, g_value_get_object (value));
+ break;
+
case PROP_HADJUSTMENT:
gtk_list_view_set_adjustment (self, GTK_ORIENTATION_HORIZONTAL, g_value_get_object (value));
break;
g_param_spec_override ("vscroll-policy",
g_object_interface_find_property (iface, "vscroll-policy"));
+ /**
+ * GtkListView:factory:
+ *
+ * Factory for populating list items
+ */
+ properties[PROP_FACTORY] =
+ g_param_spec_object ("factory",
+ P_("Factory"),
+ P_("Factory for populating list items"),
+ GTK_TYPE_LIST_ITEM_FACTORY,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
/**
* GtkListView:model:
*
*
* Creates a new empty #GtkListView.
*
- * You most likely want to call gtk_list_view_set_model() to set
- * a model and then set up a way to map its items to widgets next.
+ * You most likely want to call gtk_list_view_set_factory() to
+ * set up a way to map its items to widgets and gtk_list_view_set_model()
+ * to set a model to provide items next.
*
* Returns: a new #GtkListView
**/
return g_object_new (GTK_TYPE_LIST_VIEW, NULL);
}
+/**
+ * gtk_list_view_new_with_factory:
+ * @factory: (transfer full): The factory to populate items with
+ *
+ * Creates a new #GtkListView that uses the given @factory for
+ * mapping items to widgets.
+ *
+ * You most likely want to call gtk_list_view_set_model() to set
+ * a model next.
+ *
+ * The function takes ownership of the
+ * argument, so you can write code like
+ * ```
+ * list_view = gtk_list_view_new_with_factory (
+ * gtk_builder_list_item_factory_newfrom_resource ("/resource.ui"));
+ * ```
+ *
+ * Returns: a new #GtkListView using the given @factory
+ **/
+GtkWidget *
+gtk_list_view_new_with_factory (GtkListItemFactory *factory)
+{
+ GtkWidget *result;
+
+ g_return_val_if_fail (GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
+
+ result = g_object_new (GTK_TYPE_LIST_VIEW,
+ "factory", factory,
+ NULL);
+
+ g_object_unref (factory);
+
+ return result;
+}
+
/**
* gtk_list_view_get_model:
* @self: a #GtkListView
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
}
-void
-gtk_list_view_set_functions (GtkListView *self,
- GtkListItemSetupFunc setup_func,
- GtkListItemBindFunc bind_func,
- gpointer user_data,
- GDestroyNotify user_destroy)
+/**
+ * gtk_list_view_get_factory:
+ * @self: a #GtkListView
+ *
+ * Gets the factory that's currently used to populate list items.
+ *
+ * Returns: (nullable) (transfer none): The factory in use
+ **/
+GtkListItemFactory *
+gtk_list_view_get_factory (GtkListView *self)
{
- GtkListItemFactory *factory;
-
- g_return_if_fail (GTK_IS_LIST_VIEW (self));
- g_return_if_fail (setup_func || bind_func);
- g_return_if_fail (user_data != NULL || user_destroy == NULL);
+ g_return_val_if_fail (GTK_IS_LIST_VIEW (self), NULL);
- factory = gtk_functions_list_item_factory_new (setup_func, bind_func, user_data, user_destroy);
- gtk_list_item_manager_set_factory (self->item_manager, factory);
- g_object_unref (factory);
+ return gtk_list_item_manager_get_factory (self->item_manager);
}
+/**
+ * gtk_list_view_set_factory:
+ * @self: a #GtkListView
+ * @factory: (allow-none) (transfer none): the factory to use or %NULL for none
+ *
+ * Sets the #GtkListItemFactory to use for populating list items.
+ **/
void
-gtk_list_view_set_factory_from_bytes (GtkListView *self,
- GBytes *bytes)
+gtk_list_view_set_factory (GtkListView *self,
+ GtkListItemFactory *factory)
{
- GtkListItemFactory *factory;
-
g_return_if_fail (GTK_IS_LIST_VIEW (self));
- g_return_if_fail (bytes != NULL);
+ g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
- factory = gtk_builder_list_item_factory_new_from_bytes (bytes);
- gtk_list_item_manager_set_factory (self->item_manager, factory);
- g_object_unref (factory);
-}
-
-void
-gtk_list_view_set_factory_from_resource (GtkListView *self,
- const char *resource_path)
-{
- GtkListItemFactory *factory;
-
- g_return_if_fail (GTK_IS_LIST_VIEW (self));
- g_return_if_fail (resource_path != NULL);
+ if (factory == gtk_list_item_manager_get_factory (self->item_manager))
+ return;
- factory = gtk_builder_list_item_factory_new_from_resource (resource_path);
gtk_list_item_manager_set_factory (self->item_manager, factory);
- g_object_unref (factory);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
}
/**
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_list_view_new (void);
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_list_view_new_with_factory (GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_list_view_get_model (GtkListView *self);
void gtk_list_view_set_model (GtkListView *self,
GListModel *model);
GDK_AVAILABLE_IN_ALL
-void gtk_list_view_set_functions (GtkListView *self,
- GtkListItemSetupFunc setup_func,
- GtkListItemBindFunc bind_func,
- gpointer user_data,
- GDestroyNotify user_destroy);
-GDK_AVAILABLE_IN_ALL
-void gtk_list_view_set_factory_from_bytes (GtkListView *self,
- GBytes *bytes);
+void gtk_list_view_set_factory (GtkListView *self,
+ GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL
-void gtk_list_view_set_factory_from_resource (GtkListView *self,
- const char *resource_path);
+GtkListItemFactory *
+ gtk_list_view_get_factory (GtkListView *self);
GDK_AVAILABLE_IN_ALL
void gtk_list_view_set_show_separators (GtkListView *self,
typedef struct _GtkEventController GtkEventController;
typedef struct _GtkGesture GtkGesture;
typedef struct _GtkLayoutManager GtkLayoutManager;
+typedef struct _GtkListItemFactory GtkListItemFactory;
typedef struct _GtkNative GtkNative;
typedef struct _GtkRequisition GtkRequisition;
typedef struct _GtkRoot GtkRoot;
'gtkboxlayout.h',
'gtkbuildable.h',
'gtkbuilder.h',
+ 'gtkbuilderlistitemfactory.h',
'gtkbuilderscope.h',
'gtkbutton.h',
'gtkcalendar.h',
'gtkfontchooserdialog.h',
'gtkfontchooserwidget.h',
'gtkframe.h',
+ 'gtkfunctionslistitemfactory.h',
'gtkgesture.h',
'gtkgesturedrag.h',
'gtkgesturelongpress.h',
'gtklinkbutton.h',
'gtklistbox.h',
'gtklistitem.h',
+ 'gtklistitemfactory.h',
'gtkliststore.h',
'gtklistview.h',
'gtklockbutton.h',
gtk_widget_set_vexpand (sw, TRUE);
gtk_box_append (GTK_BOX (vbox), sw);
- listview = gtk_list_view_new ();
- gtk_list_view_set_functions (GTK_LIST_VIEW (listview),
- setup_list_item,
- bind_list_item,
- NULL, NULL);
+ listview = gtk_list_view_new_with_factory (
+ gtk_functions_list_item_factory_new (setup_list_item,
+ bind_list_item,
+ NULL, NULL));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
g_string_append_printf (string, " (%u directories remaining)", active + g_slist_length (pending));
result = G_SOURCE_CONTINUE;
}
+ result = G_SOURCE_CONTINUE;
gtk_statusbar_push (statusbar, 0, string->str);
g_free (string->str);
gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (search_entry), sw);
gtk_box_append (GTK_BOX (vbox), sw);
- listview = gtk_list_view_new ();
- gtk_list_view_set_functions (GTK_LIST_VIEW (listview),
- setup_widget,
- NULL,
- NULL, NULL);
+ listview = gtk_list_view_new_with_factory (
+ gtk_functions_list_item_factory_new (setup_widget,
+ NULL,
+ NULL, NULL));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
if (argc > 1)